import Vue from 'vue'
import dialog from '../component/dialog'

function create(Component, props) {
  const Ctor = Vue.extend(Component);
  const comp = new Ctor({ propsData: props })
  comp.$mount();
  document.querySelector('#dialogWindow').appendChild(comp.$el)
  comp.remove = () => {
    document.querySelector('#dialogWindow').removeChild(comp.$el)
    comp.$destroy()
  }
  return comp
}

// Vue.component('dialog', dialog)

Vue.prototype.$alert = ((obj) => {
  return create(dialog, obj).show()
})